package com.hex.ds.hdtp.core.app.data.table.service;

import com.hex.ds.hdtp.core.app.common.page.PageData;
import com.hex.ds.hdtp.core.app.common.page.dto.PageDto;
import com.hex.ds.hdtp.core.app.common.service.IBasicService;
import com.hex.ds.hdtp.core.app.data.table.dto.excel.TableTransferListExcelDto;
import com.hex.ds.hdtp.core.app.data.table.dto.request.TableTransferListRequestDto;
import com.hex.ds.hdtp.core.app.data.table.dto.response.TableTransferListResponseDto;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @Package com.hex.ds.hdtp.core.app.data.table.service
 * @ClassName ITableTransferListService
 * @Description 表迁移清单-业务接口
 * @Author Wang zhihao
 * @Date 2023/8/9 11:30
 * @Version v1.0
 **/
public interface ITableTransferListService extends IBasicService<TableTransferListRequestDto> {

    /**
     * 根据任务主键分页查询
     *
     * @param tableTransferListRequestDto
     * @param pageDto
     * @return
     */
    PageData queryPageListByTaskId(TableTransferListRequestDto tableTransferListRequestDto, final PageDto pageDto);

    /**
     * @param tableTransferListRequestDto
     * @Method queryList
     * @Param
     * @Return java.util.List<com.hex.ds.hdtp.core.app.data.table.dto.request.TableTransferListRequestDto>
     * @Description 不分页查询
     * @Author Wang zhihao
     * @Date 2023/8/10 14:28
     * @Version V1.0
     */
    List<TableTransferListResponseDto> queryList(TableTransferListRequestDto tableTransferListRequestDto);

    /**
     * @Method queryLatestTransferTable
     * @Param
     * @Param sourceDbName
     * @Param sourceTableName
     * @Return com.hex.ds.hdtp.core.app.data.table.dto.response.TableTransferListResponseDto
     * @Description 根据源库名表名查询最新的迁移表信息
     * @Author gj.xu
     * @Date 2023/8/29 11:52
     * @Version V2.0
     */
    TableTransferListResponseDto queryLatestTransferTable(String sourceDbName, String sourceTableName);

    /**
     * 根据目标库名表名查询最新的迁移表信息
     *
     * @param targetDbName
     * @param targetTableName
     * @param targetPkId
     * @return
     */
    TableTransferListResponseDto queryLatestTransferTableByTarget(String targetDbName, String targetTableName, String targetPkId);


    /**
     * @param pkId
     * @Method queryById
     * @Param
     * @Return com.hex.ds.hdtp.core.app.data.table.dto.response.TableTransferListResponseDto
     * @Description 根据主键获取表迁移清单信息
     * @Author Wang zhihao
     * @Date 2023/8/14 14:41
     * @Version V1.0
     */
    TableTransferListResponseDto queryById(String pkId);

    /**
     * @param pkIds
     * @Method batchRemoveById
     * @Param
     * @Return void
     * @Description 表迁移清单-批量删除
     * @Author Wang zhihao
     * @Date 2023/8/9 11:30
     * @Version V1.0
     */
    void batchRemoveById(List<String> pkIds);

    /**
     * @param taskPkId
     * @Method removeByTaskPkId
     * @Param
     * @Return void
     * @Description 表迁移清单-根据任务主键删除
     * @Author Wang zhihao
     * @Date 2023/8/9 19:31
     * @Version V1.0
     */
    void removeByTaskPkId(String taskPkId);

    /**
     * @param pkId
     * @Method buildCreateTableSql
     * @Param
     * @Return com.hex.ds.hdtp.core.app.data.table.dto.response.TableTransferListResponseDto
     * @Description 表迁移清单-建立建表语句
     * @Author Wang zhihao
     * @Date 2023/8/18 17:37
     * @Version V1.1
     */
    TableTransferListResponseDto buildCreateTableSql(String pkId);

    /**
     * @param tableTransferListRequestDto
     * @Method addWithBackId
     * @Param
     * @Return java.lang.String
     * @Description 新增并返回ID
     * @Author Wang zhihao
     * @Date 2023/8/14 10:02
     * @Version V1.0
     */
    String addWithBackId(TableTransferListRequestDto tableTransferListRequestDto);

    /**
     * @param sourceConnId
     * @param targetConnId
     * @param pkId
     * @Method getFieldMap
     * @Param
     * @Return void
     * @Description 表迁移清单-获取字段映射
     * @Author Wang zhihao
     * @Date 2023/8/14 14:46
     * @Version V1.0
     */
    void getFieldMap(String sourceConnId, String targetConnId, String pkId);

    /**
     * @param tableTransferListRequestDto
     * @param pageDto
     * @Method queryLatestSuccess
     * @Param
     * @Return com.hex.ds.hdtp.core.app.common.page.PageData
     * @Description 表迁移清单-分页查询每个建表最新成功的
     * @Author Wang zhihao
     * @Date 2023/8/28 11:07
     * @Version V1.0
     */
    PageData queryLatestSuccess(TableTransferListRequestDto tableTransferListRequestDto, PageDto pageDto);

    ByteArrayResource exportTableTransferList(List<String> pkIds);

    Map<String, Object> importTableTransferList(MultipartFile multipartFile, TableTransferListExcelDto tableTransferListExcelDto);
}
